package com.huluobo.a2201mvvm_imdemo.login;

import androidx.lifecycle.MutableLiveData;

import com.huluobo.a2201mvvm_imdemo.bean.UserBean;
import com.huluobo.a2201mvvm_imdemo.mvvm.BaseRepo;
import com.hyphenate.EMCallBack;

/**
 * Created by LC on 2024/3/22.
 */
public class LoginRepo extends BaseRepo {
    public void login(String username, String password, MutableLiveData<UserBean> success,
                      MutableLiveData<String> failed) {
        emClient.login(username, password, new EMCallBack() {
            @Override
            public void onSuccess() {
                //主线程中设置值的位置
//                success.setValue(new LoginUserBean(username, password));
                //子线程中设置值
                success.postValue(new UserBean(username, password));
            }

            @Override
            public void onError(int code, String error) {
//                failed.setValue(error);
                failed.postValue(error);
            }
        });
    }
}
